<template>
    <div class="itemMain">
        <div class="itemTit"><div>我的理想</div><div class="num">{{MyIdea.length}}/100</div></div>
        <div class="itemCont">
           <textarea rows="7" maxlength="100" @blur="blurChange" @focus="$focus"  placeholder="请输入内容，最多100字" v-model="MyIdea"></textarea>
        </div>
    </div>
</template>

<script>
import {axPost} from '@/api/index'
export default {
    data(){
        return{
            MyIdea:'',
            school:localStorage.getItem('school'),
            userid:localStorage.getItem('userid'),
        }
    },

    methods:{
        blurChange(){
            this.$blur()
            sessionStorage.setItem('hasChange3',true)
        },
        submit(type){
            let state = 0
            // if(!this.MyIdea.match(/^[ ]*$/)){
            if(this.MyIdea != ''){
                state = 1
            }
            if(type === 'myideal'){
                const myideainfo ={
                    MyIdea:this.MyIdea,
                    IdeaState:state
                }
               axPost('ChangQingAddOrUpdateGrowRecord',{
                   school:this.school,
                   userid:this.userid,
                   myideainfo:myideainfo
               }).then((res)=>{
                   if(res.ResultCode == 1){
                      sessionStorage.getItem('hasChange3') && sessionStorage.removeItem('hasChange3')
                       this.$Tips({
                            content:'提交成功',
                            icon:'correct'
                        })
                        this.$emit('update')
                   }else{
                       this.$Tips({
                            content:'提交失败',
                        }) 
                   }
               })
           }
        }
    }
}
</script>

<style lang='scss' scoped>
.itemMain{
    width: 100%;
    height: 100%;
    padding: .3rem;
    overflow: auto;
   .itemTit{
        width: 100%;
        font-size: .32rem;
        color: #262727;
        font-weight: bold;
        display: flex;
        justify-content: space-between;
        .num{
            color: #B6B8B8;
            font-size: .24rem;
            font-weight: normal;
        }
    }
    .itemCont{
      width: 100%;
      height: 1.24rem;
      margin-top: .1rem;
      textarea{
        border: #E4E5E6 1px solid;
        padding:.12rem;
        width: 100%;
        resize: none;
      }
    }
  
}
</style>